#include "common.hpp"

int main()
{
    //获取
    key_t shm_key = getKey();

    printf("shm_key: 0X%x\n", shm_key);

    int shmid = createShm(shm_key);
    printf("shmid: %d\n", shmid);

    sleep(3);

    char *start = (char*)attchShm(shmid);
    printf("arrchShm success , address start : %p\n", start);
    sleep(5);

    size_t cnt = 0;
    while (cnt <= 10)
    {
        sleep(1);
        printf("Im want to say : %s\n", start);
        ++cnt;
    }

    //去关联
    deattchShm(start);

    sleep(3);

    //删除共享内存
    delShm(shmid);

    return 0;
}